home *** CD-ROM | disk | FTP | other *** search
/ CD Concept 6 / CD Concept 06.iso / mac / UTILITAIRE / Little Smalltalk v3.1.4 / C Source / Sources / CLStDoc.cp < prev    next >
Text File  |  1994-10-15  |  4KB  |  133 lines

  1. //=============================================================================
  2. //    Little Smalltalk, version 3
  3. //    Written by Tim Budd, Oregon State University, July 1988
  4. //
  5. //    Symantec Think Class Library interface code 
  6. //        ⌐Julian Barkway, April 1994, all rights reserved.
  7. //
  8. //    CLStDoc.cp
  9. //    ----------
  10. //    This class provides basic document related functions.
  11. //
  12. //  v3.1.2 - Minimum window size decreased to 75x75
  13. //=============================================================================
  14.  
  15. #include <string.h>
  16. #include "Global.h"
  17. #include "Commands.h"
  18. #include "CApplication.h"
  19. #include "CBartender.h"
  20. #include "CDataFile.h"
  21. #include "CDecorator.h"
  22. #include "CDesktop.h"
  23. #include "CError.h"
  24. #include "CPanorama.h"
  25. #include "TBUtilities.h"
  26. #include "CLStDoc.h"
  27. #include "CTextPane.h"
  28. #include "CLStWindow.h"
  29. #include "CLStApp.h"
  30. #include "LStResources.h"
  31.  
  32. #define    LSTWIN_MIN        75
  33.  
  34. extern    CApplication     *gApplication;    /* The application */
  35. extern    CBartender        *gBartender;    /* The menu handling object */
  36. extern    CDecorator        *gDecorator;    /* Window dressing object    */
  37. extern    CDesktop        *gDesktop;        /* The enclosure for all windows */
  38. extern    CBureaucrat        *gGopher;        /* The current boss in the chain of command */
  39. extern    OSType            gSignature;        /* The application's signature */
  40. extern    CError            *gError;        /* The error handling object */
  41.  
  42. extern CLStApp        *gSmalltalk;
  43.  
  44.  
  45. //==============================================================================
  46. // Initialise a Document object.
  47. //==============================================================================
  48. void CLStDoc::ILStDoc (CApplication *super, Boolean printable)
  49. {
  50.     CDocument::IDocument (super, printable);
  51. }
  52.  
  53.  
  54. //==============================================================================
  55. // Make a window.
  56. //==============================================================================
  57. CWindow *CLStDoc::BuildWindow (char *title, Point *wPosition, Point *wSize)
  58. {
  59.     Str255    wTitle;
  60.     Rect    sr;
  61.     
  62.     itsWindow = new    (CLStWindow);
  63.     itsWindow->IWindow (WTemplate, FALSE, gDesktop, this);
  64.     if (title != NULL) {
  65.         strcpy  ((char *)wTitle, title);
  66.         CtoPstr ((char *)wTitle);
  67.         itsWindow->SetTitle (wTitle);
  68.     }
  69.     
  70.     SetRect (&sr, LSTWIN_MIN, LSTWIN_MIN, 
  71.              screenBits.bounds.right, screenBits.bounds.bottom);    
  72.     itsWindow->SetSizeRect (&sr);
  73.     
  74.     gDecorator->PlaceNewWindow (itsWindow);
  75.  
  76.     if (wPosition != NULL)
  77.         itsWindow->Move (wPosition->h, wPosition->v);
  78.         
  79.     if (wSize != NULL)
  80.         itsWindow->ChangeSize (wSize->h, wSize->v);
  81.         
  82.     itsWindow->Select ();
  83.     ((CLStWindow *)itsWindow)->itsDocument = this;
  84.     return itsWindow;
  85. }
  86.  
  87.  
  88. //==============================================================================
  89. // Set the file type for this document. Allows specification of types other than
  90. // 'TEXT'
  91. //==============================================================================
  92. void CLStDoc::SetFileType (long fType)
  93. {
  94.     fileType = fType;
  95. }
  96.  
  97.  
  98. //==============================================================================
  99. // Return the document's window.
  100. //==============================================================================
  101. CWindow *CLStDoc::GetWindow (void)
  102. {
  103.     return itsMainPane->GetWindow ();
  104. }
  105.  
  106.  
  107. //==============================================================================
  108. // Process the standard file requester.
  109. //==============================================================================
  110. void CLStDoc::AskFileName (char *promptString, Boolean save, StandardFileReply *sfReply,
  111.                            SFTypeList fTypes, short numFTypes)
  112. {
  113.     Point            location;
  114.     Str255            str;
  115.         
  116.     if (save) {
  117.         strcpy    ((char *)str, promptString);
  118.         CtoPstr   ((char *)str);
  119.         StandardPutFile (str, "\p", sfReply);
  120.     }
  121.     else
  122.         StandardGetFile (NULL, numFTypes, fTypes, sfReply);
  123. }
  124.  
  125.  
  126. //={OVERRIDE}==================================================================
  127. // Close confirmation handled by Smalltalk.
  128. //=============================================================================
  129. Boolean    CLStDoc::ConfirmClose (Boolean quitting)
  130. {
  131.     return TRUE;
  132. }
  133.